<?

/**
* insert into detail
*
* @param  string  $COracle
* @param  string  $values
* @param  string  $srcDb
*
*/ 
function insToDbDtl(&$COracle,
                    &$values,
                    &$srcDb){

  $query = "INSERT INTO ".$srcDb." 
            (JOB_ID,
             ORDER_DATE,
             ORDER_REF,
             ORDER_NO,
             ICAT,
             IGROUP,
             MODEL,
             MODEL_ID,
             UNIT,
             QUANTITY,
             CVT_TO,
             CVT_QTY,
             DLVR_QTY,
             PRICE,
             HRZ_TOT,
             NO)
            VALUES (".$values.") ";
  
  $COracle->execQuery($query);
}

/**
* insert into header
* 
* @param  string  $COracle
* @param  string  $values
* @param  string  $srcDb
*
*/
function insToDbHdr(&$COracle,
                    &$values,
                    &$srcDb){

  $query  = "INSERT INTO ".$srcDb." 
             (JOB_ID,
              REFERENCE,
              TR_DATE,
              NO,
              STATUS)
             VALUES (".$values.") ";
  
  $COracle->execQuery($query);
}

/**
* update the receive qty
* 
* @param  string  $COracle
* @param  string  $odrRef       order REFERENCE
* @param  string  $odrNo        order No
* @param  string  $currDlvrQty  current receive qty
* @param  string  $srcDb
*
*/
function updateDlvrQty( &$COracle,
                        &$odrRef,
                        &$odrNo,
                        &$currDlvrQty,
                        &$srcDb){

  $query  = "UPDATE ".$srcDb." 
             SET DLVR_QTY=".$currDlvrQty." 
             WHERE  JOB_ID='".$odrRef."' 
                    AND NO=".$odrNo." ";
                    
  $COracle->execQuery($query);
}

/**
* update the status of this jobId
* 
* @param  string  $COracle
* @param  string  $odrRef       order REFERENCE
* @param  boolean $isOutstanding
* @param  boolean $isBtbIssued
* @param  string  $srcDb
*
*/
function updateStatus( &$COracle,
                       &$odrRef,
                       &$isOutstanding,
                       &$isBtbIssued,
                       &$isActive,
                       &$srcDb){
                        
  if($isBtbIssued == true){
    
    $status = _BTB_ISSUED;
  }else
  if($isOutstanding == true){
    
    $status = _OUTSTANDING;
  }else{
    
    $status = _ACTIVE;
  }
  
  $query  = "UPDATE ".$srcDb." 
             SET  STATUS='".$status."'
             WHERE  JOB_ID='".$odrRef."' ";
             
  $COracle->execQuery($query); 
}
?>